4
4
.
.
2
2
.
.
4
4
V
V
S
S
t
t
a
a
c
c
k
k
I
I
n
n
f
f
o
o
[
[
R
R
]
]
[
[
R
R
]
]
VStack is Container View which organizes his child Views vertically on top of each other.
You can't have empty VStack.
When adding Views to the Screen you can choose to
insert into existing VStack
insert into new VStack
Enclose existing View inside VStack (You can use this either in the Code or Automatic Preview)
Command + Click on the View + Embed in HStack
Syntax
VStack(alignment: .leading, spacing: 200)
Parameters
NAME
DESCRIPTION
VStack(alignment: .leading)
Align child views to the left
VStack(alignment: .center)
Align child views to the right
VStack(alignment: .trailing)
Align child views to the right
VStack(spacing: 20)
Space between children. Instead of using Spacer()
E
E
x
x
a
a
m
m
p
p
l
l
e
e
In this example we create VStack with two Text Views and some Spacers between them.
Example
VStack {
Spacer()
Text("First Line")
Spacer()
Text("Second Line")
Spacer()
}
Output